package com.cmsky.open.food.model;

import java.util.HashSet;
import java.util.Set;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;

import cn.org.rapid_framework.util.DateConvertUtils;

import com.cmsky.open.base.model.AreaInfo;
import com.cmsky.open.core.base.BaseEntity;
import com.cmsky.open.shop.model.ShopInfo;
import com.cmsky.open.user.model.UserInfo;

/**
 * @author jandyfish email:jandyfish(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


public class FoodOrderInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "FoodOrderInfo";
	public static final String ALIAS_ID = "编号";
	public static final String ALIAS_USER_ID = "订餐用户";
	public static final String ALIAS_AREA_ID = "大厦";
	public static final String ALIAS_SHOP_ID = "商户";
	public static final String ALIAS_FOOD_ID = "餐品";
	public static final String ALIAS_NUM = "份数";
	public static final String ALIAS_ONE_PRICE = "单份价格";
	public static final String ALIAS_ALL_PRICE = "总额";
	public static final String ALIAS_ORDER_TIME = "预定日期";
	public static final String ALIAS_REGIST_TIME = "下单时间";
	public static final String ALIAS_STATE = "单号状态";
	public static final String ALIAS_MARK = "备注";
	public static final String ALIAS_PAY_STATE = "支付状态";
	public static final String ALIAS_PAY_TYPE = "支付方式";
	
	//date formats
	public static final String FORMAT_ORDER_TIME = DATE_FORMAT;
	public static final String FORMAT_REGIST_TIME = DATE_FORMAT;
	
	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * 编号       db_column: id 
     */	
	
	private java.lang.Integer id;
    /**
     * 订餐用户       db_column: user_id 
     */	
	@NotNull 
	private java.lang.Integer userId;
    /**
     * 大厦       db_column: area_id 
     */	
	@NotNull 
	private java.lang.Integer areaId;
    /**
     * 商户       db_column: shop_id 
     */	
	
	private java.lang.Integer shopId;
    /**
     * 餐品       db_column: food_id 
     */	
	@NotNull 
	private java.lang.Integer foodId;
    /**
     * 份数       db_column: num 
     */	
	@NotNull 
	private java.lang.Integer num;
    /**
     * 单份价格       db_column: one_price 
     */	
	@NotNull 
	private java.lang.Float onePrice;
    /**
     * 总额       db_column: all_price 
     */	
	@NotNull 
	private java.lang.Float allPrice;
    /**
     * 预定日期       db_column: order_time 
     */	
	@NotNull 
	private java.util.Date orderTime;
    /**
     * 下单时间       db_column: regist_time 
     */	
	@NotNull 
	private java.util.Date registTime;
    /**
     * 单号状态       db_column: state 
     */	
	@NotNull 
	private java.lang.Integer state;
    /**
     * 备注       db_column: mark 
     */	
	@Length(max=50)
	private java.lang.String mark;
    /**
     * 支付状态       db_column: payState 
     */	
	@NotNull @Max(127)
	private Integer payState;
    /**
     * 支付方式       db_column: payType 
     */	
	@Max(127)
	private Integer payType;
	//columns END

	public FoodOrderInfo(){
	}

	public FoodOrderInfo(
		java.lang.Integer id
	){
		this.id = id;
	}

	public void setId(java.lang.Integer value) {
		this.id = value;
	}
	
	public java.lang.Integer getId() {
		return this.id;
	}
	public void setUserId(java.lang.Integer value) {
		this.userId = value;
	}
	
	public java.lang.Integer getUserId() {
		return this.userId;
	}
	public void setAreaId(java.lang.Integer value) {
		this.areaId = value;
	}
	
	public java.lang.Integer getAreaId() {
		return this.areaId;
	}
	public void setShopId(java.lang.Integer value) {
		this.shopId = value;
	}
	
	public java.lang.Integer getShopId() {
		return this.shopId;
	}
	public void setFoodId(java.lang.Integer value) {
		this.foodId = value;
	}
	
	public java.lang.Integer getFoodId() {
		return this.foodId;
	}
	public void setNum(java.lang.Integer value) {
		this.num = value;
	}
	
	public java.lang.Integer getNum() {
		return this.num;
	}
	public void setOnePrice(java.lang.Float value) {
		this.onePrice = value;
	}
	
	public java.lang.Float getOnePrice() {
		return this.onePrice;
	}
	public void setAllPrice(java.lang.Float value) {
		this.allPrice = value;
	}
	
	public java.lang.Float getAllPrice() {
		return this.allPrice;
	}
	public String getOrderTimeString() {
		return DateConvertUtils.format(getOrderTime(), FORMAT_ORDER_TIME);
	}
	public void setOrderTimeString(String value) {
		setOrderTime(DateConvertUtils.parse(value, FORMAT_ORDER_TIME,java.util.Date.class));
	}
	
	public void setOrderTime(java.util.Date value) {
		this.orderTime = value;
	}
	
	public java.util.Date getOrderTime() {
		return this.orderTime;
	}
	public String getRegistTimeString() {
		return DateConvertUtils.format(getRegistTime(), FORMAT_REGIST_TIME);
	}
	public void setRegistTimeString(String value) {
		setRegistTime(DateConvertUtils.parse(value, FORMAT_REGIST_TIME,java.util.Date.class));
	}
	
	public void setRegistTime(java.util.Date value) {
		this.registTime = value;
	}
	
	public java.util.Date getRegistTime() {
		return this.registTime;
	}
	public void setState(java.lang.Integer value) {
		this.state = value;
	}
	
	public java.lang.Integer getState() {
		return this.state;
	}
	public void setMark(java.lang.String value) {
		this.mark = value;
	}
	
	public java.lang.String getMark() {
		return this.mark;
	}
	public void setPayState(Integer value) {
		this.payState = value;
	}
	
	public Integer getPayState() {
		return this.payState;
	}
	public void setPayType(Integer value) {
		this.payType = value;
	}
	
	public Integer getPayType() {
		return this.payType;
	}
	
	private Set foodOrderItemInfos = new HashSet(0);
	public void setFoodOrderItemInfos(Set<FoodOrderItemInfo> foodOrderItemInfo){
		this.foodOrderItemInfos = foodOrderItemInfo;
	}
	
	public Set<FoodOrderItemInfo> getFoodOrderItemInfos() {
		return foodOrderItemInfos;
	}
	
	private UserInfo userInfo;
	
	public void setUserInfo(UserInfo userInfo){
		this.userInfo = userInfo;
	}
	
	public UserInfo getUserInfo() {
		return userInfo;
	}
	
	private FoodInfo foodInfo;
	
	public void setFoodInfo(FoodInfo foodInfo){
		this.foodInfo = foodInfo;
	}
	
	public FoodInfo getFoodInfo() {
		return foodInfo;
	}
	
	private AreaInfo areaInfo;
	
	public void setAreaInfo(AreaInfo areaInfo){
		this.areaInfo = areaInfo;
	}
	
	public AreaInfo getAreaInfo() {
		return areaInfo;
	}
	
	private ShopInfo shopInfo;
	
	public void setShopInfo(ShopInfo shopInfo){
		this.shopInfo = shopInfo;
	}
	
	public ShopInfo getShopInfo() {
		return shopInfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("UserId",getUserId())
			.append("AreaId",getAreaId())
			.append("ShopId",getShopId())
			.append("FoodId",getFoodId())
			.append("Num",getNum())
			.append("OnePrice",getOnePrice())
			.append("AllPrice",getAllPrice())
			.append("OrderTime",getOrderTime())
			.append("RegistTime",getRegistTime())
			.append("State",getState())
			.append("Mark",getMark())
			.append("PayState",getPayState())
			.append("PayType",getPayType())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof FoodOrderInfo == false) return false;
		if(this == obj) return true;
		FoodOrderInfo other = (FoodOrderInfo)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.append(getUserId(),other.getUserId())
			.append(getAreaId(),other.getAreaId())
			.append(getShopId(),other.getShopId())
			.append(getFoodId(),other.getFoodId())
			.append(getNum(),other.getNum())
			.append(getOnePrice(),other.getOnePrice())
			.append(getAllPrice(),other.getAllPrice())
			.append(getOrderTime(),other.getOrderTime())
			.append(getRegistTime(),other.getRegistTime())
			.append(getState(),other.getState())
			.append(getMark(),other.getMark())
			.append(getPayState(),other.getPayState())
			.append(getPayType(),other.getPayType())
			.isEquals();
	}
}

